<template>
    <div class="header">
      <div class="content-wrapper">
        <div class="avatar">
          <img width="64" height="64" :src="seller.avatar" alt="">
        </div>
        <div class="content">
          <div class="title">
            <span class="brand"></span>
            <span class="name">{{seller.name}}</span>
          </div>
          <div class="description">
            {{seller.description}}/{{seller.deliveryTime}}分钟送达
          </div>
          <div v-if="seller.supports" class="supports">
            <span class="icon" :class="classMap[seller.supports[0].type]"></span>
            <span class="text">{{seller.supports[0].description}}</span>
          </div>
        </div>
        <div class="support-count" @click="handleCountClick">
          <span class="count">5个</span>
          <span class="iconfont">&#xe606;</span>
        </div>
      </div>
      <div class="header-ads" @click="handleCountClick">
        <span class="ads-title"></span>
        <span class="ads-info">{{seller.bulletin}}</span>
        <span class="iconfont icon-right">&#xe606;</span>
      </div>
      <div class="background">
        <img :src="seller.avatar" width="100%" height="100%" alt="">
      </div>
      <Fade-Animation>
        <div class="detail" v-show="showDetail">
          <div class="detail-wrapper clearfix">
            <div class="detail-content">
              <h1 class="name">{{seller.name}}</h1>
              <star :score="seller.score" :size="48" class="star"></star>
              <div class="detail-line">
                <div class="line border-bottom"></div>
                <div class="info">优惠信息</div>
                <div class="line border-bottom"></div>
              </div>
              <ul v-if="seller.supports" class="support">
                <li class="support-item" v-for="(item, index) of seller.supports" :key="index">
                  <span class="icon" :class="classMap[seller.supports[index].type]"></span>
                  <span class="text">{{seller.supports[index].description}}</span>
                </li>
              </ul>
              <div class="detail-line">
                <div class="line border-bottom"></div>
                <div class="info">商家公告</div>
                <div class="line border-bottom"></div>
              </div>
              <div class="bulletin">
                <p class="text">{{seller.bulletin}}</p>
              </div>
            </div>
          </div>
          <div class="detail-close" @click="handleCloseClick">
            <span class="iconfont">&#xe602;</span>
          </div>
        </div>
      </Fade-Animation>
    </div>
</template>
<script>
import Star from '../star/Star'
import FadeAnimation from '../../common/fade/FadeAnimation'
export default {
  name: 'Header',
  props: {
    seller: Object
  },
  components: {
    Star,
    FadeAnimation
  },
  data () {
    return {
      showDetail: false
    }
  },
  created () {
    this.classMap = ['decrease', 'discount', 'guarantee', 'invoice', 'special']
  },
  methods: {
    handleCountClick () {
      this.showDetail = true
    },
    handleCloseClick () {
      this.showDetail = false
    }
  }
}
</script>

<style lang="stylus" scoped>
  @import "../../assets/stylus/mixin.styl"
  .header
    background-color rgba(7,17,27,0.5)
    color #fff
    position relative
    .content-wrapper
      padding 24px 12px 18px 24px
      overflow hidden
      position relative
      .avatar
        float left
        img
          border-radius 2px
      .content
        float left
        margin-left 16px
        .title
          margin 2px 0 8px 0
          .brand
            display inline-block
            vertical-align top
            width 30px
            height 18px
            background url("./brand@2x.png")
            bg-image('brand')
            background-size 30px 18px
            background-repeat no-repeat
          .name
            margin-left 6px
            font-size 16px
            line-height 16px
            font-weight bold
        .description
            font-size 12px
            line-height 12px
            color rgb(255,255,255)
            font-weight 200
            margin-bottom 10px
        .supports
          .icon
            display inline-block
            width 12px
            height 12px
            margin-right 4px
            background-size 12px 12px
            background-repeat no-repeat
            &.decrease
              bg-image('decrease_1')
            &.discount
              bg-image('discount_1')
            &.guarantee
              bg-image('guarantee_1')
            &.invoice
              bg-image('invoice_1')
            &.special
              bg-image('special_1')
          .text
            font-size 10px
            line-height 12px
            color rgb(255,255,255)
            font-weight 200
      .support-count
        position absolute
        right 12px
        bottom 18px
        padding 0 8px
        border-radius 14px
        height 24px
        line-height 24px
        text-align center
        background rgba(0,0,0,0.2)
        .count
          vertical-align top
          font-size 10px
          line-height 24px
    .header-ads
      position relative
      height 28px
      padding 0 22px 0 12px
      line-height 28px
      white-space nowrap
      overflow hidden
      text-overflow ellipsis
      background-color rgba(7,17,27,0.2)
      overflow hidden
      .ads-title
        display block
        float left
        margin-top 9px
        width 22px
        height 12px
        bg-image('bulletin')
        background-size 22px 12px
        background-repeat no-repeat
      .ads-info
        margin-left 4px
        font-size 10px
        line-height 28px
        font-weight 200
      .icon-right
        position absolute
        right 12px
        top 2px
        font-size 16px
    .background
      z-index -1
      position absolute
      left 0
      top 0
      width 100%
      height 100%
      filter blur(10px)
    .detail
      z-index 100
      position fixed
      top 0
      left 0
      width 100%
      height 100%
      overflow auto
      background rgba(7,17,27,0.8)
      .detail-wrapper
        min-height 100%
        .detail-content
          margin-top 64px
          padding-bottom 64px
          .name
            font-size 16px
            line-height 16px
            font-weight 700
            color rgb(255,255,255)
            text-align center
          .star
            margin 16px auto 28px auto
            text-align center
          .detail-line
            display flex
            padding 0 36px
            margin-bottom 24px
            .line
              flex 1
              coloer rgba(255,255,255,0.2)
              position relative
              top -6px
            .info
              padding 0 12px
          .support
            padding 0 12px
            margin-bottom 28px
            .support-item
              width 80%
              margin 0 auto
              margin-bottom 12px
              font-size 12px
              font-weight 200
              color rgb(255,255,255)
              &:last-child
                margin-bottom 0
              .icon
                float left
                margin-right 6px
                display block
                width 16px
                height 16px
                background-size 16px 16px
                background-repeat no-repeat
                margin-top -2px
                &.decrease
                  bg-image('decrease_2')
                &.discount
                  bg-image('discount_1')
                &.guarantee
                  bg-image('guarantee_1')
                &.invoice
                  bg-image('invoice_1')
                &.special
                  bg-image('special_1')
          .bulletin
            width 80%
            margin 0 auto
            .text
              padding 0 12px
              font-size 12px
              font-weight 200
              line-height 24px
              color rgb(255,255,255)
      .detail-close
        position relative
        width 32px
        height 32px
        margin -64px auto 0 auto
        clear both
        font-size 32px
        color rgba(255,255,255,0.5)
</style>
